Update UserInfo.kt#6
Conversation
- Add snake_case SerializedName for multiple word parameters. - Set updatedAt type to Int.
There was a problem hiding this comment.
Pull request overview
This PR updates the UserInfo data class to properly map JSON responses from the /me endpoint using Gson annotations. The changes ensure field names match the snake_case convention used in the API response and correct the data type for the updatedAt field.
- Adds
@SerializedNameannotations to all fields to explicitly map snake_case JSON keys to camelCase Kotlin properties - Changes
updatedAttype fromString?toInt?to match the actual API response format
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @SerializedName("sub") | ||
| val sub: String, | ||
| @SerializedName("email") |
There was a problem hiding this comment.
The @SerializedName annotations for 'sub' and 'email' are unnecessary since the JSON keys already match the Kotlin property names. Remove these redundant annotations to reduce clutter and follow the convention of only annotating fields where the names differ.
| @SerializedName("sub") | |
| val sub: String, | |
| @SerializedName("email") | |
| val sub: String, |
| val email: String, | ||
| @SerializedName("preferred_username") | ||
| val preferredUsername: String?, | ||
| @SerializedName("name") |
There was a problem hiding this comment.
The @SerializedName annotation for 'name' is unnecessary since the JSON key matches the Kotlin property name. Consider removing this redundant annotation.
| @SerializedName("name") |
| val givenName: String?, | ||
| @SerializedName("family_name") | ||
| val familyName: String?, | ||
| @SerializedName("groups") |
There was a problem hiding this comment.
The @SerializedName annotation for 'groups' is unnecessary since the JSON key matches the Kotlin property name. Consider removing this redundant annotation.
| @SerializedName("groups") |
UserInfo fields with snake_case JSON keys (preferred_username, given_name, family_name, updated_at) were silently deserializing as null because Gson performs exact name matching against the camelCase Kotlin property names. Also changes updatedAt from String? to Long? to match the OIDC spec (updated_at is a Unix epoch timestamp), adds ProGuard consumer rules to prevent R8 from stripping Gson model fields, and adds deserialization tests. Supersedes #6, #13, #16. [no-ado]
|
Thanks for the contribution — this correctly identified that One issue: I've opened PR #23 which combines the fixes from this PR, PR #13, and PR #16, with the correct |
Update the
UserInfoclass to match the JSON keys returned from the/meendpoint and parsed with Gson.